<!DOCTYPE html>
<html class=" ">
  
{% include 'header.html' %}
  
  <body class="">

    {% include 'left.html' %}

    <main>
      {% include 'banner.html' %}
      <div class="container-fluid">
        <h1 class="bread-crumb">
          <strong>
            漏洞检测 / 添加扫描
          </strong>
        </h1>
        <form class="form-horizontal" action="" method="POST" data-action="notpjax">
            {% csrf_token %}
          <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label">
              目标地址
            </label>
            <div class="col-xs-8">
              <textarea id="domain" name="domain" class="form-control" rows="6" placeholder="http://www.bilibili.com
支持多行输入" ></textarea>
            </div>
          </div>
          <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label">
              任务名称
            </label>
            <div class="col-xs-8 form-inline">
              <input id="task_name" name="task_name" class="form-control" placeholder="主站扫描" type="text">
              <span class="form-control-static">
                用来查看你的任务扫描状态
              </span>
            </div>
          </div>
          <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label">
              扫描模块
            </label>
            <div class="col-xs-8 form-inline">
              <input id="poc_name" name="poc_name" class="form-control" placeholder="struts2" type="text">
              <span class="form-control-static">
                如网站使用strus2,填入status2,扫描只会调用扫描struts2规则,不指定将使用所有扫描规则
              </span>
            </div>
          </div>
          <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label">
              检测模式
            </label>
            <div class="col-xs-8 form-inline">
              <select name="scan_mode" class="form-control" id="scan-mode">
                <option value="0" data="0" selected="selected">
                  默认模式
                </option>
                <option value="1" data="1">
                  专家模式(未开发)
                </option>
              </select>
            </div>
          </div>
          <div class="form-group form-group-sm">
            <div class="col-xs-offset-2 col-xs-8">
              <button type="button" onclick="add_task()" name="submit" value="add_task" class="btn btn-sm">
                启动扫描
              </button>
            </div>
          </div>
        </form>

      </div>
    </main>

  </body>
<script>
    function add_task(){
        var domains = document.getElementById('domain').value;
        var scan_domain = (domains.replace(/\n/g,","));
        var task_name = document.getElementById('task_name').value;
        var poc_name = document.getElementById('poc_name').value;
        $.post('/scan/',{
            'domains': scan_domain,
            'poc_name': poc_name,
            'task_name': task_name,
            'mode': 1,
            'csrfmiddlewaretoken':'{{ csrf_token }}' },
                function(status){
			      if(status.status==200){
				    alert('添加成功');
                  }
                  if(status.status==1){
				    alert('目标都已有扫描结果或正在扫描');
                  }
		});
    }
</script>
</html>